package JDBC;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.Statement;
/*
* 删除数据*/
public class Text05 {
    public static void main(String[] args) {
        Connection connection=null;
        Statement statement=null;
        try {
            Class.forName("oracle.jdbc.driver.OracleDriver");
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
        try {
             connection = DriverManager.getConnection(
                    "jdbc:oracle:thin:@127.0.0.1:1521:orcl",
                    "kz",
                    "root"
            );
        } catch (SQLException e) {
            e.printStackTrace();
        }

        try {
             statement = connection.createStatement();
        } catch (Exception e) {
            e.printStackTrace();
        }
        String sql="Delete  from dept where deptno=60";
        try {
            statement.execute(sql);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        try {
            connection.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
        try {
            statement.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }
}
